<template>
	<page-meta><navigation-bar title="详情" front-color="#000000" background-color="#ffffff" /></page-meta>
	<view>
		<view class="dingyue" style="overflow: hidden;">
			<!-- <view @tap="open(i)" v-for="i,index in nowlst" style="width: calc(100% - 70px);position: relative; margin: 0 auto;background: #fff;border-radius: 6px;margin-top: 15px;padding: 15px 20px;"> -->
			<view v-for="i,index in nowlst" style="width: calc(100% - 70px);position: relative; margin: 0 auto;background: #fff;border-radius: 6px;margin-top: 15px;padding: 15px 20px;">
				<view style="padding-bottom: 8px;font-size: 18px;">{{i.accountNo?i.accountNo:'--'}} -> {{i.nickName?i.nickName:'--'}}</view>
				<view style="font-size: 14px;color: rgba(0,0,0,.6);padding-bottom: 8px;">
					<text>策略：{{i.tacticsDescSign == 1?'传统策略':'组合策略'}}</text>
					<text style="padding-left: 15px;">倍数：{{i.nums}}</text>
					<text style="float: right;position: absolute;right: 15px;top: 50%;transform: translateY(-50%); font-size: 16px;margin-bottom: 240rpx;display: inline-block;" :style="{color:i.state == 1?'#4680b0':'#ccc'}">{{i.state == 1?'正常':'关闭'}}</text>
				</view>
				<view style="font-size: 12px;color: rgba(0,0,0,.6);">{{i.addtime.replace('T',' ')}}</view>
			</view>
			<uni-text v-if="!nowlst.length" style="height: 400x;font-size: 16px;text-align: center;display: block;color: red;padding-top: 150px;">
				暂无订阅信息！
				<!-- <navigator url="../center/setshi" style="color:#168deb ;display: inline-block;">去添加</navigator> -->
			</uni-text>
		</view>
		<view style="background: #fff;padding: 20px 25px;position: fixed;bottom: 0;left: 0;width: calc(100% - 50px);">
			<button type="default" style="color: #fff;margin-bottom: 10px;background: #168deb;" @tap="shilogin(3)">终止订阅</button>
			<!-- <button type="default" style="color: #fff;" @tap="shilogi+n(0)">取消</button> -->
		</view>
		<uni-popup type="bottom" ref="settypess">
			<view style="background: #fff;padding: 20px 25px;">
				<button type="default" style="color: red;margin-bottom: 10px;" @tap="shilogin(3)">终止订阅</button>
				<button type="default" style="background: #168deb;color: #fff;" @tap="shilogin(0)">取消</button>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dylst:[],
				uid:0,
				nowobj:{}
			}
		},
		computed:{
			nowlst(){
				var lst = [];
				for(var i in this.dylst){
					var o = this.dylst[i];
					if(this.uid == o.tradeUserId){
						lst.push(o);
					}
				};
				this.nowobj = lst[0];
				return lst;
			}
		},
		onLoad(e) {
			this.uid = e.uid?e.uid:'';
		},
		methods: {
			getdata(){
				this.getdy();
			},
			getdy() {
				var _this = this;
				uni.request({
					url: _this.$store.state.url1 + '/api/FollowSetting/GetFollowingList?token=' + this.$store.state.user.token,
					method: 'get',
					// data: _this.param,
					success: res => {
						// console.log(res)
						res = res.data;
						// console.log(res);
						// console.log(_this.searchdata)
						if (res.code == 200) {
							_this.dylst = res.data;
						} else {
							
						}
					},
					fail: res => {
						console.log(res);
					}
				});
			},
			shilogin(type){
				var _this = this;
				if(type == 0){
					this.close()
					return;
				}
				uni.request({
					url: _this.$store.state.url1 + '/api/FollowSetting/EditSheQuAppRATIOFollow?token=' + this.$store.state.user.token+'&id='+_this.nowobj.id+'&state=3',
					method: 'get',
					// data: _this.param,
					success: res => {
						// console.log(res);
						res = res.data;
						
						if (res.code == 200) {
							
								uni.showToast({
									title: '已终止！',
									duration: 1500
								});
								setTimeout(function(){
									uni.navigateBack();
								},1500)
							_this.close()
						} else {
							uni.showToast({
								title: res.msg,
								icon: 'none',
								duration: 2500
								// position:'top'
							});
						}
					},
					fail: res => {
						console.log(res);
					}
				});
			},
			open(obj) {
				this.$refs.settypess.open();
				this.nowobj = obj;
			},
			close() {
				this.$refs.settypess.close();
			}
		},
		onShow() {
			this.height = uni.getSystemInfoSync().windowHeight-40;
			var _this = this;
			uni.getNetworkType({
				success: function(res) {
					if (res.networkType == 'none') {
						uni.showToast({
							title: '当前无网络连接，请检查！',
							icon: 'none',
							duration: 5000
		
							// position:'top'
						});
					}
				}
			});
			uni.onNetworkStatusChange(function(res) {
				if (!res.isConnected) {
					uni.showToast({
						title: '当前无网络连接，请检查！',
						icon: 'none',
						duration: 3000
						// position:'top'
					});
				} else {
					uni.showToast({
						title: '网络已连接！',
						icon: 'none',
						duration: 3000
						// position:'top'
					});
					_this.getdata();
				}
			});
			
			this.getdata();
		}
	}
</script>

<style>

</style>
